﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using System.Linq;

namespace Booking.Models
{

    public class testClass
    {
        public int t1;
        public int t2;

        private const string TableName = "testTable";

        public static testClass Load()
        {
            if (!ConnectionDb.IsOpened) ConnectionDb.OpenDb();
            testClass order = null;
            var adapter = new SqlDataAdapter(String.Format("SELECT * FROM {0}", TableName), ConnectionDb.Connection);
            var ds = new DataSet();
            adapter.Fill(ds, TableName);
            if (ds.Tables[TableName].Rows.Count > 0)
            {
                order = new testClass();
                var dr = ds.Tables[TableName].Rows[0];
                order.t1 = int.Parse(dr["t1"].ToString());
                order.t2 = int.Parse(dr["t2"].ToString());
            }
            return order;
        }
    }
}
